package com.framework.modules.sys.controller;

import com.framework.entity.sys.SysBank;
import com.framework.exception.util.RespResult;
import com.framework.page.PageUtils;
import com.framework.service.BankService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 银行卡相关
 * @author wq
 */
@RestController
@RequestMapping("/sys/bank")
public class BankCardController extends  AbstractController{

    @Autowired
    private BankService bankService;

    /**
     * 银行卡列表
     * @param params
     * @return
     */
    @RequestMapping("/list")
    @RequiresPermissions("sys:bank:list")
    public RespResult queryBankList(@RequestParam Map<String,Object> params){
        params.put("deptId",getUser().getDeptId());
        PageUtils page=bankService.queryBankCardList(params);
        return RespResult.ok().put("page",page);
    }
    /**
     * 获取银行卡信息
     * @param bankId
     * @return
     */
    @RequestMapping("/queryById/{bankId}")
    @RequiresPermissions("sys:bank:list")
    public RespResult queryById(@PathVariable Long bankId){
        SysBank bank=bankService.queryById(bankId);
        return RespResult.ok().put("bank",bank);
    }
    /**
     * 修改银行卡
     * @param bank
     * @return
     */
    @RequestMapping("/updateBank")
    @RequiresPermissions("sys:bank:update")
    public RespResult updateBank(@RequestBody SysBank bank){
        bankService.updateById(bank);
        return RespResult.ok();
    }
}
